//
//  YDHomePageCell.m
//  YDTestDrive
//
//  Created by ios on 2017/2/13.
//  Copyright © 2017年 ios. All rights reserved.
//

#import "YDHomePageCell.h"
#import "YDPassengerModel.h"


@interface YDHomePageCell ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subTitlelabel;
@property (weak, nonatomic) IBOutlet UIButton *statusButton;//客流状态
@end
@implementation YDHomePageCell


- (void)setPassangerModel:(YDPassengerModel *)passangerModel
{
    _passangerModel = passangerModel;
    
    if (passangerModel.customerName.length > 0) {
        
        self.titleLabel.text = passangerModel.customerName;
    } else {
        self.titleLabel.text = [NSString stringWithFormat:@"到店%ld人", [passangerModel.count integerValue]];
    }
    
    self.subTitlelabel.text = [NSString stringWithFormat:@"到店时间: %@", passangerModel.trialCreateTimeString];
    
    //状态: 1未完善; 2已完善; 3非意向; 默认为1
    NSInteger status = [passangerModel.status integerValue];
    if (status == 1) {
        [self.statusButton setTitle:@"待完善" forState:UIControlStateNormal];
        [self.statusButton setTitleColor:[UIColor colorWithHexString:@"f98089"] forState:UIControlStateNormal];
        [self.statusButton setBackgroundImage:[UIImage imageNamed:@"home_state_red"] forState:UIControlStateNormal];
    } else if (status == 2) {
        [self.statusButton setTitle:@"已完善" forState:UIControlStateNormal];
        [self.statusButton setTitleColor:[UIColor colorWithHexString:@"7ed1a5"] forState:UIControlStateNormal];
        [self.statusButton setBackgroundImage:[UIImage imageNamed:@"home_state_green"] forState:UIControlStateNormal];
    } else {
        [self.statusButton setTitle:@"非意向" forState:UIControlStateNormal];
        [self.statusButton setTitleColor:[UIColor colorWithHexString:@"feb324"] forState:UIControlStateNormal];
        [self.statusButton setBackgroundImage:[UIImage imageNamed:@"home_state_yellow"] forState:UIControlStateNormal];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
